package com.hakim.wfb.customer.enums;

/**
 * 是否可以购票
 * Created by caochong on 2016/6/13.
 */
public enum OrderStatusEnum {
    WAIT_TICKET(1, "wait_ticket"),//等待出票
    TICKET_SUCCESS(2, "ticket_success"),//出票成功
    TICKET_FAILED(3, "ticket_failed"),//出票失败
    REFUNDING(4, "refunding"),//退票中
    REFUND_SUCCESS(5, "refund_success"),//退票成功
    REFUND_FAILED(6, "refund_failed"),//退票失败
    REVERSE_SUCCESS(7, "reverse_success"),//冲正成功
    ;

    private int code;

    private String message;

    private OrderStatusEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }


    public static OrderStatusEnum getByCode(int code) {
        OrderStatusEnum[] codes = values();
        for (OrderStatusEnum each : codes) {
            if (each.code == code) {
                return each;
            }
        }
        return null;
    }

    public static OrderStatusEnum getByMsg(String msg) {
        OrderStatusEnum[] codes = values();
        for (OrderStatusEnum each : codes) {
            if (each.message.equals(msg)) {
                return each;
            }
        }
        return null;
    }
}
